/**
 * Created on Oct 7, 2004
 */
package com.hermeneute.fsa.editors.outline;

import java.util.Set;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.editors.text.TextEditor;

import com.hermeneute.fsa.parser.FSTParserTree;
import com.hermeneute.fsa.parser.FSTParserTreeTK;

import antlr.CommonAST;
import antlr.RecognitionException;
import antlr.TokenStreamException;
import antlr.collections.AST;


/**
 * @author Phil Zoio
 */
public class OutlineContentProvider implements ITreeContentProvider
{
	FSTParserTree p;
	FSTParserTreeTK ptk;
	public OutlineContentProvider() {
		super();
	}
	
	public FSTParserTreeTK getParser() {
		return ptk;
	}
	public Object[] getChildren(Object parentElement) {
		if (parentElement instanceof TextEditor) {
			String editorText = ((TextEditor)parentElement).getDocumentProvider().
				getDocument(((TextEditor)parentElement).getEditorInput()).get();
			ptk = new FSTParserTreeTK(editorText);
			return ptk.getRootChildren();
		}
		return new Object[0];
	}

	public Object getParent(Object element) {
		return null;
	}

	public boolean hasChildren(Object element) {
		return false;
	}

	public Object[] getElements(Object inputElement) {
		return getChildren(inputElement);
	}

	public void dispose() {
	}

	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		//System.out.println("oldInput "+oldInput);
		//System.out.println("newInput "+newInput);
	}
	
}